import * as React from 'react';
import {observer} from 'mobx-react';
import {toJS} from 'mobx';
import { Tree } from 'antd';

const TreeNode = Tree.TreeNode;

@observer
export class AdTreeShow extends React.Component<{store: any},any>{
    render(){
        const loop = data => data.map((item) => {
            if (item.children) {
                return (
                    <TreeNode key={item.key} title={item.label}>
                        {loop(item.children)}
                    </TreeNode>
                );
            }
            
            return <TreeNode key={item.key} title={item.label} />;
        });

        return (
            <Tree>
                {loop(toJS(this.props.store.showTreeData))}
            </Tree>
        )
    }   
}